<template>
  <div style="padding:30px;">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="新密码">
        <el-input v-model="form.newPassword" />
      </el-form-item>
      <el-form-item label="确认密码">
        <el-input v-model="form.password" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" plain @click="changePassword()">提交</el-button>
        <el-button type="" plain>重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { changePassword } from '@/api/user'
import { Message } from 'element-ui'
export default {
  data() {
    return {
      form: {
        oldPassword: '',
        newPassword: '',
        uid: ''
      }
    }
  },
  computed: {
    ...mapGetters([
      'uid',
      'roles',
      'name',
      'deptName',
      'account'
    ])
  },
  methods: {
    changePassword() {
      this.form.uid = this.uid
      changePassword(this.form).then(response => {
        if (response.code === 200) {
          Message.success('保存成功')
        } else {
          Message.error('保存失败')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.el-input{
  width: 300px;
}
</style>
